package cn.yh.register.hosp.controller;

import cn.yh.register.common.result.Result;
import cn.yh.register.hosp.service.HospitalService;
import cn.yh.register.model.hosp.Hospital;
import cn.yh.register.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院管理接口")
@RestController
//@CrossOrigin
@RequestMapping("/admin/hosp/hospital")
public class HospitalController {
    @Autowired
    HospitalService hospitalService;

    @ApiOperation(value = "分页查询医院列表")
    @GetMapping("{page}/{limit}")
    public Result<Page<Hospital>> index(
            @ApiParam(name = "page", value = "当前页码", required = true)
            @PathVariable Integer page,
            @ApiParam(name = "limit", value = "每页记录数", required = true)
            @PathVariable Integer limit,
            @ApiParam(name = "queryVo", value = "查询对象", required = false)
                    HospitalQueryVo queryVo) {
        return Result.ok(hospitalService.findHospitalPage(page, limit, queryVo));
    }
    @ApiOperation("医院状态上线/下线")
    @GetMapping("updateStatus/{id}/{status}")
    public Result<?> updateStatus(@PathVariable String id,@PathVariable Integer status){
            hospitalService.updateStatus(id,status);
            return Result.ok();
    }

    @ApiOperation("查看医院详情")
    @GetMapping("show/{id}")
    public Result<Map<String, Object>> detail(@PathVariable String id){
        Map<String, Object> map = hospitalService.show(id);
        return Result.ok(map);
    }

}
